package com.bawei.search.model

import com.bawei.common.entity.SimpleVideoEntity
import com.bawei.common.model.BaseRepository
import com.bawei.search.api.SearchServerApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

/**
 * Author: Jason Zhang
 * Date: 2025/2/5
 * Desc: 搜索网络仓库
 */
class SearchRepository  @Inject constructor(private val apiServer: SearchServerApi): BaseRepository<SearchServerApi>(){


    suspend fun getSimpleVideoByKeyword(keyword: String, page: Int, pageSize: Int): Flow<List<SimpleVideoEntity>> {
        return flow {
            var result = apiServer.getSimpleVideoByKeyword(keyword, page, pageSize)
            if (result.code == 0){
                emit(result.data)
            }else{
                emit(listOf())
            }
        }
    }




}